<template>
  <div class="card-container">
    <div class="card-item" @click="handleClick">
      <div class="imgBox">
        <el-image class="img" fit="fill" :src="book.img"></el-image>
      </div>
      <div class="content-info">
        <div class="title">{{ book.name }}</div>
        <div class="count">
          <div class="price">￥{{ book.price }}</div>
          <div class="buynumber">
            <span>{{ book.count }}</span
            >学员购买
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ElMessage } from "element-plus";
export default {
  props: {
    book: {
      type: Object,
      required: true,
    },
  },
  setup() {
    const handleClick = () => {
      ElMessage({
        message: "别点了,没做这功能。",
        type: "warning",
        center: true,
      });
    };

    return {
      handleClick,
    };
  },
};
</script>

<style lang="less" scoped>
.card-item {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  align-items: center;
  width: 220px;
  height: 300px;
  margin-bottom: 25px;
  cursor: pointer;
  background-color: rgb(255, 255, 255);
  transition: all 0.5s;
  border-radius: 10px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3), -2px -2px 5px rgba(0, 0, 0, 0.3);
  .imgBox {
    width: 220px;
    height: 220px;
    .img {
      width: 100%;
      height: 100%;
      border-radius: 10px;
    }
  }
  .content-info {
    display: flex;
    justify-content: center;
    flex-direction: column;
    .title {
      margin: 10px 0;
      font-size: 15px;
      width: 180px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .count {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
      .price {
        color: red;
      }
      .buynumber {
        font-size: 12px;
        color: rgb(161, 164, 179);
        span {
          color: red;
        }
      }
    }
  }
}
.card-item:hover {
  transform: scale(105%);
  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.3), -5px -5px 5px rgba(0, 0, 0, 0.3);
}
</style>
